﻿@model RoleViewModel

@{
    var x = Html.X();
    Html.EnableClientValidation();
}


@(x.Window().Layout(LayoutType.Fit)
          .CloseAction(CloseAction.Destroy)
          .Width(1000).Height(600)
          .Items(
              x.FormPanel().Default().Layout(LayoutType.Fit)
                  .Items(
                      x.TabPanel().Items(
                          x.Panel().Title("基本信息").Layout(LayoutType.Column).Defaults(new
                          {
                              padding = 4,
                              columnWidth = .333
                          })
                          .Items(
                              x.HiddenFor(i => i.Id),
                              x.TextFieldFor(i => i.Name),
                              x.TextAreaFor(i => i.Remark).ColumnWidth(1)
                              ),
                          x.Panel().Title("包含用户").Layout(LayoutType.Fit).Items(
                              x.GridPanel()
                              .TopBar(x.Toolbar().Items(x.Button().Text("添加用户")))
                                  .Store(x.StoreForModel().RemoteFilter(true)
                                      .Proxy(x.AjaxProxy().Url(Url.Action("GetPaged", "User", new { roleId = Model.Id })).Post().Reader(x.JsonReader().RootProperty("data")))
                                      .RemoteSort(true).RemotePaging(true).PageSize(25)
                                      .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC))
                                  .SelectionModel(x.CheckboxSelectionModel().Mode(SelectionMode.Multi))
                                  .ColumnModel(
                                      x.RowNumbererColumn().Align(ColumnAlign.End).Width(60),
                                      x.ColumnFor(Model.UserIndexModel, m => m.UserName),
                                      x.ColumnFor(Model.UserIndexModel, m => m.Email)
                                  )
                                  .BottomBar(x.PagingToolbar().ItemsFromPartial("~/Views/Shared/_PagingToolbarPartial.cshtml"))
                                  .EmptyText("无数据。")
                                  .View(Html.X().GridView().StripeRows(true).TrackOver(true))
                              )
                          )

                  )
                  .Buttons(
                      x.Button().Text("提交").Icon(Icon.Disk)
                          .DirectEvents(de =>
                          {
                              de.Click.Action = "Save";
                              de.Click.EventMask.ShowMask = true;
                              de.Click.EventMask.Msg = "正在提交...";
                              de.Click.Success = "App.Edit.PostBackSuccess";
                          }),
                      x.Button().Text("关闭").Icon(Icon.Cancel).OnClientClick("App.Edit.CloseWindow(this)")
                  )
          ))